package com.empire.module.member.dal.mysql.mappolygon;

import java.util.*;

import com.empire.framework.common.pojo.PageResult;
import com.empire.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.empire.framework.mybatis.core.mapper.BaseMapperX;
import com.empire.module.member.dal.dataobject.mappolygon.MapPolygonDO;
import org.apache.ibatis.annotations.Mapper;
import com.empire.module.member.controller.admin.mappolygon.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 地图多边形信息 Mapper
 *
 * @author 主席大人
 */
@Mapper
public interface MapPolygonMapper extends BaseMapperX<MapPolygonDO> {

    default PageResult<MapPolygonDO> selectPage(MapPolygonPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MapPolygonDO>()
                .eqIfPresent(MapPolygonDO::getConfigId, reqVO.getConfigId())
                .likeIfPresent(MapPolygonDO::getName, reqVO.getName())
                .eqIfPresent(MapPolygonDO::getStrokeColor, reqVO.getStrokeColor())
                .eqIfPresent(MapPolygonDO::getStrokeWeight, reqVO.getStrokeWeight())
                .eqIfPresent(MapPolygonDO::getFillColor, reqVO.getFillColor())
                .eqIfPresent(MapPolygonDO::getFillOpacity, reqVO.getFillOpacity())
                .eqIfPresent(MapPolygonDO::getRoomLevel, reqVO.getRoomLevel())
                .eqIfPresent(MapPolygonDO::getSortOrder, reqVO.getSortOrder())
                .eqIfPresent(MapPolygonDO::getArea, reqVO.getArea())
                .eqIfPresent(MapPolygonDO::getPointCount, reqVO.getPointCount())
                .orderByDesc(MapPolygonDO::getId));
    }

    // 根据配置ID查询多边形
    @Select("select * from member_map_polygon where config_id = #{configId}")
    List<MapPolygonDO> selectByConfigId(@Param("configId") String configId);
}